import request from '@/utils/request';
import {ElMessage} from 'element-plus'


/**
 * 查询文章详细信息
 * @returns {Promise<any>}
 */
export async function selectArticleDetail(params) {
    const res = await request.get('/site/cms/article/detail', {params});
    if (res.data.code === 200) {
        return res.data;
    }
    return Promise.reject(ElMessage.error(res.data.msg));
}


/**
 * 分页查询文章信息
 */
export async function pageArticles(params) {
    const res = await request.get('/site/cms/article/list', {params});
    if (res.data.code === 200) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 获取文章列表
 * @param typeId
 * @returns {Promise<any>}
 */
export async function selectArticleTopList(params) {
    const res = await request.get('/site/cms/article/top/list', {params});
    if (res.data.code === 200) {
        return res.data;
    }
    return Promise.reject(ElMessage.error(res.data.msg));
}


/**
 * 查询文章详细信息
 * @returns {Promise<any>}
 */
// export async function selectArticleDetail(articleId) {
//     let data = {
//         articleId
//     };
//     const res = await request.get('/site/cms/nav/item/list/', {data});
//     if (res.data.code === 200) {
//         return res.data;
//     }
//     return Promise.reject(ElMessage.error(res.data.msg));
// }